package com.idis.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Ming on 2018/1/30.
 */

/**
 * 简介服务
 */
@Service
public class IntroService {

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    String DBUrl;

    private String INTRO ="/intro";

    private String FIND_ALL="/all";

    private String UPDATE="/update";

    /**
     * 获取简介
     * @return 简介
     */
    public String findAll(){
        String intro= restTemplate.exchange(DBUrl+INTRO+FIND_ALL, HttpMethod.GET, null, String.class).getBody();
        return intro;
    }

    /**
     * 更新简介，ID必须
     * @param introduction 简介
     * @return 成功更新的数量
     */
    public Integer update(String  introduction){
        return restTemplate.postForObject(DBUrl+INTRO+UPDATE,introduction,Integer.class);
    }
}
